package com.wangan.wanganpush.stomp.RelinkMap;

import java.util.Iterator;
import java.util.Map;

import org.springframework.web.socket.messaging.WebSocketStompClient;

import com.gs.collections.impl.map.mutable.ConcurrentHashMap;

/**
 * stomp连接缓存
 * @author xfm
 * 2018年12月25日
 */
public class LinkMap {
	
	//存放订阅的连接
	public static Map<String, WebSocketStompClient> linkMap = new ConcurrentHashMap<String, WebSocketStompClient>();
	
	
	public static boolean addStompLink(String LinkName,WebSocketStompClient stompClint){
		if(linkMap.get("LinkName") != null) return false;
		linkMap.put(LinkName, stompClint);
		return true;
	}
	
	
	public static boolean removeAllStompLink(){
		if(linkMap.size() == 0)return false;
		Iterator keys= linkMap.keySet().iterator();
		while(keys.hasNext()){
			WebSocketStompClient w =linkMap.get(keys.next());
			System.out.println(w.toString());
			w.stop();
		}
		linkMap.clear();
		return true;
	}

}

